<template>
    <div>
        <h2>修改信息</h2>
        <div class="FromGood">
            <el-form :model="story" ref="goodFrom" label-width="120px" class="demo-ruleForm">
                <el-form-item label="通知标题" prop="role">
                    <el-input v-model="story.role" placeholder="请输入标题"></el-input>
                </el-form-item>
                <el-form-item label="通知类型" prop="abstracts">
                    <el-input v-model="story.abstracts" placeholder="类型"></el-input>
                </el-form-item>
                <el-form-item label="通知内容" prop="deed">
                    <el-input v-model="story.deed" placeholder="内容"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="submitForm('product')">提交</el-button>
                </el-form-item>
            </el-form>
        </div>
        
    </div>

</template>

<script>
    //发送post请求携带数据时需要导入该模块
    import Qs from 'qs'

    export default {
        data(){
            return {
                story:{
                    role:'',
                    abstracts:'',
                    deed:'',
                    image:''
                },
                storyId:'',
                imageUrl: '',

            }
        },
        methods: {
            
            submitForm(){
                var vm=this;
                this.axios({
                    method:'post',
                    url:'/story/update',
                    transformRequest: [function (data) {
                        return Qs.stringify(data)
                    }],
                    data: vm.story
                }).then(function (response) {
                    if (response.data==='success'){
                        vm.$message({
                            message: '修改成功',
                            type: 'success'
                        });
                        vm.$router.push("/story/index")
                    }else{
                        vm.$message.error('修改失败');
                    }
                })
            },
            getById() {
                this.storyId=this.$route.params.storyId;
                var vm=this;
                this.axios({
                    method:'get',
                    url:'/story/findById/'+vm.storyId
                }).then(function(response) {
                    vm.story=response.data;
                })
            }
        },
        created() {
            this.getById()
        }
    }
</script>

<style scoped>
    .FromGood{
        width: 100%;
        min-height: 100%;
        padding: 15px;
        box-sizing: border-box;
    }
</style>